package com.woniu.user.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.after.client.RefundsApplyManageClient;
import com.woniu.after.client.ReturnGoodsManageClient;
import com.woniu.after.client.param.RefundsApplyParam;
import com.woniu.after.client.param.ReturnGoodsParam;
import com.woniu.result.Result;
import com.woniu.user.client.AfterManageClient;
import com.woniu.user.client.param.UserRefundsApplyParam;
import com.woniu.user.client.param.UserReturnGoodsParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class UserAfterApiImpl implements AfterManageClient {

    @Resource
    private RefundsApplyManageClient refundsApplyManageClient;
    @Resource
    private ReturnGoodsManageClient returnGoodsManageClient;

    /**
     * 退款申请
     * @param refundsApplyParam
     * @return
     */
    @Override
    public Result refundsApply(UserRefundsApplyParam refundsApplyParam) {
       log.info("检查退款申请参数：{}", refundsApplyParam);
        RefundsApplyParam refundsApplyParam1 = BeanUtil.copyProperties(refundsApplyParam, RefundsApplyParam.class);
        //TODO userId
        refundsApplyParam1.setUserId(1);
        refundsApplyParam1.setUserNum("1");
        return  refundsApplyManageClient.refundsApply(refundsApplyParam1);
    }

    /**
     * 退货
     * @param returnGoodsParam
     * @return
     */
    @Override
    public Result userReturnGoods(UserReturnGoodsParam returnGoodsParam) {
        log.info("检查退货申请参数：{}", returnGoodsParam);
        ReturnGoodsParam returnGoodsParam1 = BeanUtil.copyProperties(returnGoodsParam, ReturnGoodsParam.class);
        return returnGoodsManageClient.userReturnGoods(returnGoodsParam1);
    }
}
